package cn.pomit.springbootwork.consulclient.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cn.pomit.springbootwork.consulclient.model.ResultModel;
import cn.pomit.springbootwork.consulclient.service.IpInfoService;
import cn.pomit.springbootwork.consulclient.service.UserConfig;

@RestController
@RequestMapping("/consulClient")
public class ConsulClientRest {
	@Autowired
	IpInfoService ipInfoService;
	@Autowired
	UserConfig userConfig;
	
	@Value("${hello.message}")
	private String message;
	
	@RequestMapping(value = "/ip", method = { RequestMethod.GET })
	public ResultModel ip() {
		return ipInfoService.getIpInfo();
	}
	
	@RequestMapping(value = "/value", method = { RequestMethod.GET })
	public ResultModel value() {
		return ResultModel.ok(ipInfoService.testValue());
	}
	
	@RequestMapping(value = "/test", method = { RequestMethod.GET })
	public ResultModel test() {
		return ResultModel.ok(userConfig.toString());
	}
	
	@RequestMapping(value = "/message", method = { RequestMethod.GET })
	public ResultModel message() {
		return ResultModel.ok(message);
	}
}
